
#!/bin/bash
set -x
arch=$1
current_build_dir=$1/build
current_source_dir=.
deb_path=$current_source_dir/$arch/deb
deb_package_path=$current_source_dir/$arch/deb/package
echo "current_build_dir:$current_build_dir"
echo "current_source_dir:$current_source_dir"
echo "arch:$arch"
echo "deb_path:$deb_path"
echo "deb_package_path:$deb_package_path"
remote_ip=39.99.206.18
remote_user=root
remote_pwd=ibse@51909065
#remote_prefix_dir=/root/mirrors/ubuntu/dists/focal/main
remote_prefix_dir=/root/mirrors

if [[ "$arch" == "aarch64" ]]; then
  remote_dir=$remote_prefix_dir/ubuntu-aarch64
elif [[ "$arch" == "arm" ]]; then
  remote_dir=$remote_prefix_dir/binary-armhf
elif [[ "$arch" == "x86_64" ]]; then
  remote_dir=$remote_prefix_dir/binary-amd64
elif [[ "$arch" == "i386" ]]; then
  remote_dir=$remote_prefix_dir/binary-i386
else
  echo "invalid arch:$arch"
  exit
fi
echo "remote_dir:$remote_dir"

sshpass -p $remote_pwd scp $deb_package_path/* $remote_user@$remote_ip:$remote_dir
sshpass -p $remote_pwd ssh $remote_user@$remote_ip "cd $remote_dir && sudo dpkg-scanpackages .|gzip >Packages.gz"

